package com.qdsg.ysg.doctor.ui.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qdsg.ysg.doctor.R;
import com.rest.response.PrescriptionListResponse;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by HP on 2020/3/2.
 */

public class SecondListAdapter extends RecyclerView.Adapter<SecondListAdapter.Holder> {

    private AppCompatActivity context;
    private List<PrescriptionListResponse.Second> list;


    public SecondListAdapter(AppCompatActivity context, List<PrescriptionListResponse.Second> list, boolean isGuoYao) {
        this.context = context;
        this.list = list;
    }

    @NotNull
    @Override
    public SecondListAdapter.Holder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        SecondListAdapter.Holder myHolder;
        myHolder = new Holder( LayoutInflater.from( context ).inflate( R.layout.item_second_diagnose_list, parent, false ) );
        return myHolder;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(SecondListAdapter.Holder holder, final int position) {

        holder.main.setText( list.get( position ).preAppend + "-" + list.get( position ).icd + "-" + list.get( position ).tailAppend );

    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    static class Holder extends RecyclerView.ViewHolder {

        TextView main;


        Holder(View itemView) {
            super( itemView );
            main = itemView.findViewById( R.id.main );
        }
    }


}
